# !/usr/bin/python
# -*- coding: UTF-8 -*-
# 使用方式
# python  sendEmail.py  "邮件标题"  "邮件内容"

import sys
import smtplib
from email.mime.text import MIMEText
from email.header import Header

# 发件人的的账号 - 可以改动
sender = '895111863@qq.com'

# 接收邮件，可设置为你的QQ邮箱或者其他邮箱 - 可以改动
receivers = ['1835064412@qq.com' , '3208628698@qq.com', '1061070468@qq.com']


#配置发送人的邮箱数据 - 不要改动
username = '895111863@qq.com'
password = 'papdmswgcxmlbfbd'

#SMTP邮箱服务器 - 不要改动
mail_host = 'smtp.qq.com'

def send_mail(title, content):
    try:
        msg = MIMEText(content,'plain','utf-8')
        if not isinstance(title,unicode):
            title = unicode(title, 'utf-8')
        msg['Subject'] = title
        msg['From'] = sender
        msg['To'] = Header(''.join(receivers), 'utf-8')
        msg["Accept-Language"]="zh-CN"
        msg["Accept-Charset"]="ISO-8859-1,utf-8"

        smtp = smtplib.SMTP_SSL()
        smtp.connect(mail_host, 465)  # 465 为 SMTP 端口号
        smtp.login(username, password)
        smtp.sendmail(sender, receivers, msg.as_string())
        smtp.quit()
        print "邮件发送成功!"

    except Exception, e:
        print str(e)
        print "邮件发送失败!"



#if send_mail(sys.argv[1], sys.argv[2]):
#    print "邮件发送成功!"
#else:
#    print "邮件发送失败!"
